const mysql = require('mysql2/promise');

async function checkAreasPrimaryKey() {
  const connection = await mysql.createConnection({
    host: '43.143.253.188',
    user: 'nextjs',
    password: 'yEAiRE2jcxTyRBy5',
    database: 'nextjs'
  });

  try {
    console.log('🔍 检查areas表主键...');
    
    // 获取表结构
    const [columns] = await connection.execute('SHOW COLUMNS FROM areas');
    console.log('\n📋 areas表所有字段:');
    columns.forEach(col => {
      console.log(`  ${col.Field}: ${col.Type} ${col.Null === 'NO' ? 'NOT NULL' : 'NULL'} ${col.Key ? col.Key : ''} ${col.Default ? `DEFAULT ${col.Default}` : ''}`);
    });
    
    // 检查主键
    const [indexes] = await connection.execute('SHOW INDEX FROM areas');
    console.log('\n🔑 areas表索引:');
    indexes.forEach(idx => {
      console.log(`  ${idx.Key_name}: ${idx.Column_name} (${idx.Non_unique ? '非唯一' : '唯一'})`);
    });
    
  } catch (error) {
    console.error('❌ 检查areas表主键失败:', error.message);
  } finally {
    await connection.end();
  }
}

checkAreasPrimaryKey();
